module.exports = class AsyncParallelHook {
  constructor(args){
      this.tasks = []
  }
  tapAsync(name,task){
   this.tasks.push(task)
  }
  callAsync(...args){
   const finalCallback = args.pop()
   let index = 0;
   function done(){
    if(++index === this.tasks.length){
      finalCallback()
    }
   }
   this.tasks.forEach(task => {
     task(...args,done)
   })
  }
  tapPromise(name,task){
   this.tasks.push(task)
  }
  promise(...args){
   const tasks = this.tasks.map(task => task(...args))
   return Promise.all(tasks)
  }
}
